import { useEffect, useRef } from "react";
import { getData } from "./utils";
import * as echarts from "echarts";
import "./index.less";
const Seller = () => {
  const sellerRef = useRef<HTMLDivElement>(null);
  let myEcharts: echarts.ECharts | null = null;
  //   初始化echarts
  const initEcharts = () => {
    myEcharts = echarts.init(sellerRef.current, "dark");
    getData((res) => {
      myEcharts!.setOption(res);
    }).then((data) => {
      myEcharts!.on("mouseover", () => {
        clearInterval(data.timer);
      });
    });
  };

  useEffect(() => {
    initEcharts();
  }, []);
  return <div className="serller-container" ref={sellerRef}></div>;
};

export default Seller;
